//<template>

    <div>
        <table>
            <tr>
                <th>商品名</th>
                <th>价格</th>
                <th>封面</th>
                <th>操作</th>
            </tr>
            <tr v-for="i in abc" :key="i.id">
                <td>{{ i.name }}</td>
                <td>{{ i.price }}</td>
                <td><img :src="url+i.img" width="150"></td>
                <td><button @click="del(i.id)">删除</button></td>
            </tr>
        </table>
    </div>
</template>

<script>
import axios from 'axios'
export default {
    // name:'classpeople',
    data(){
        return{
            abc:[],
            url:'http://127.0.0.1:8000'
        }
    },
    methods:{
        showpeople(){
            let id = this.$route.params.id
            axios({
                url:'http://127.0.0.1:8000/app03/goodshow/',
                method:'get',
                params:{'id':id}
            }).then(res=>{
                
                this.abc = res.data
                console.log(res.data)
            })
        },
        del(id){
            let form_data = new FormData
            form_data.append('id',id)
            axios({
                url:'http://127.0.0.1:8000/app03/goodshow/',
                method:'delete',
                data:form_data
            }).then(res=>{
                console.log(res.data)
                if(res.data.code==200){
                    this.showpeople()
                }
            })
        }
    },
    created(){
        this.showpeople()
    }
}
</script>

<style>

</style>
